﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Security.AccessControl;
using System.Security.Claims;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using AesonBaseFramework.EntityFramework.BaseEntities;
using AesonIdentityLibrary.Repositories;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;

namespace AesonIdentityLibrary.DataModel
{

    public class ApplicationUser : AesonBaseEntity, IUser<int>
    {
      
        public static ApplicationUser CreatUser(string name, string email)
        {
            return new ApplicationUser()
            {
               // GuId = Id = Guid.NewGuid().ToString(),
                UserName = name,
                EMail =  email
            };
        }

      
        public virtual string PasswordHash { get; set; }
        public virtual string SecurityStamp { get; set; }
      
        public virtual string UserName { get; set; }
        public virtual string EMail { get; set; }

        public virtual ICollection<UserClientAppAssignation> AuthorizedClientApplication { get; set; }

        public virtual ICollection<UserAuthorizationAssignation> UserAuthorizationAssignation { get; set; }

        public async Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
            // Add custom user claims here
            return userIdentity;
        }


    }




}
